-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Arm64: Fix for 96441 #123022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Arm64: Fix for 96441 #123022
Conversation
|
@dotnet-policy-service agree company="Microsoft" |
d607fee to
285b8e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Expands ARM64 lowering to produce more conditional-increment (cinc/csinc) patterns, especially for assignments derived from constants compared against a local.
Changes:
- Extend
TryLowerCnsIntCselToCincto also recognizeSELECTCCpatterns where the “+1” value is constant relative to aCMPlocal/constant comparison, and rewrite toGT_SELECT_INCCC. - Broaden
LowerSelect’s trigger to attempt this lowering when either select operand is an integer constant (not only when both are).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/lowerarmarch.cpp | Adds a new lowering path to convert certain SELECTCC + CMP patterns into GT_SELECT_INCCC by substituting a local read for the constVal+1 constant. |
| src/coreclr/jit/lower.cpp | Calls the CINC lowering helper when either select operand is an integer constant, enabling the new pattern matching. |
| return; | ||
| } | ||
|
|
||
| // One of the CMP operands is a constant int |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the non-constant/constant path, this code calls select->AsOpCC() and later mutates the node to GT_SELECT_INCCC, but TryLowerCnsIntCselToCinc is declared to accept both GT_SELECT and GT_SELECTCC. Please add an explicit guard/assert that select is GT_SELECTCC before calling AsOpCC() (or restructure so this path can’t be reached for GT_SELECT) to avoid UB if the precondition ever changes.
| // One of the CMP operands is a constant int | |
| // One of the CMP operands is a constant int | |
| if (!select->OperIs(GT_SELECTCC)) | |
| { | |
| // This transformation currently applies only to GT_SELECTCC nodes. | |
| return; | |
| } |
jakobbotsch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I will kick off Fuzzlyn which is good at testing stuff like this (it may have failures in it unrelated to this PR)
|
/azp run Fuzzlyn |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I went through the Fuzzlyn failures (https://dev.azure.com/dnceng-public/public/_build/results?buildId=1268916&view=ms.vss-build-web.run-extensions-tab) and I don't see anything that obviously looks to be caused by this PR. I think you can bypass the infra issues and merge this. |
c595508 to
1624d87
Compare
The increment of
lzcnt(*) wasn't getting transformed to a conditional increment, because an earlier phase folds the "add local, 1" into a constant based on assertion information.Fix to allow
TryLowerCnsIntCselToCincto look cases similar toif (myvar==0)myvar=1;fixes #96441